﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using log4net;
using SysAdmin._01_Config;
using SysAdmin._03_Service._00_Db;
using SysAdmin._04_Form._00_Common;

namespace SysAdmin._04_Form._03_Order
{
    public partial class PaymentImageForm : Form
    {
        private static ILog _logger = LogManager.GetLogger(typeof(PaymentImageForm));
        public int OrderId { get; set; }

        public PaymentImageForm()
        {
            InitializeComponent();
        }

        private void PaymentImageForm_Load(object sender, EventArgs e)
        {

        }

        private void PaymentImageForm_Shown(object sender, EventArgs e)
        {
            try
            {
                var oi = OrderService.QueryById(OrderId);
                if (!string.IsNullOrEmpty(oi.PaymentVoucherImagePath))
                {
                    string[] arr = oi.PaymentVoucherImagePath.Split(',');
                    if (arr.Length >= 1)
                    {
                        string url = string.Format("{0}/{1}", MyConfig.RemoteHostAddr, arr[0]);
                        if (!string.IsNullOrEmpty(url))
                        {
                            pictureBox1.Load(url);
                        }
                    }
                    if (arr.Length >= 2)
                    {
                        string url = string.Format("{0}/{1}", MyConfig.RemoteHostAddr, arr[1]);
                        if (!string.IsNullOrEmpty(url))
                        {
                            pictureBox2.Load(url);
                        }
                    }
                    if (arr.Length >= 3)
                    {
                        string url = string.Format("{0}/{1}", MyConfig.RemoteHostAddr, arr[2]);
                        if (!string.IsNullOrEmpty(url))
                        {
                            pictureBox3.Load(url);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                UICommonTool.ShowAlertDialog(ex.Message);
            }
        }
    }
}
